package com.Merlin.myapplication.kotlin

fun main() {
    val animal = Dog("Max")
    animal.makeSound()
    val animal2 = Cat("Max")
    animal2.makeSound()
}

open class Animal(var name: String) {
    open fun makeSound() {
        println("$name 发出声音")
    }
}

class Dog(name: String) : Animal(name) {
    override fun makeSound() {
        println("$name 汪汪汪")
    }
}

class Cat(name: String) : Animal(name) {
    override fun makeSound() {
        println("$name 喵喵喵")
    }
}